package net.ddyule.www.ddyule;

import android.annotation.TargetApi;
import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;

public class MyReceiver extends BroadcastReceiver {
    private static String TAG = "232";
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "onReceive: 收到广播");
        Log.d(TAG, intent.getAction());
        //拿到传来过来数据
        String msg = intent.getStringExtra("msg");
        //拿到锁屏管理者
        MainActivity.makeScreenOn();
        KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
        if (km.isKeyguardLocked()) {   //为true就是锁屏状态下
//            //启动Activity
//            Intent alarmIntent = new Intent(context, AlertActivity.class);
//            //携带数据
//            alarmIntent.putExtra("msg", msg);
//            //activity需要新的任务栈
//            alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            context.startActivity(alarmIntent);
        }
    }
}
